package Date;

import java.text.SimpleDateFormat;

/**
 * 解析字符串为时间
 * @author CJJ
 * @date 2025/4/9
 */
public class Date {
    public static void main(String[] args) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String input = args.length == 0 ? "1818-11-11" : args[0];

        System.out.print(input+"Parses as");

        java.util.Date t;

        try {
            t = format.parse(input);
            System.out.println("a valid date.");
        } catch (Exception e) {
            System.out.println("an invalid date.");
        }
    }
}
